-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct Color for RichText links in Dark Mode #2404
Conversation
…he text is formatted
…ch the pattern of Android
Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job! |
Hey @chipsnyder 👋 thanks for the very well detailed PR!
I know this fixes the issue but I'm not 100% sure about passing it along with the text prop, but of course, we have the issue with React Native not allowing a way to enforce the order. My knowledge of Aztec is very limited so I was wondering what @mchowning thinks about it. Matt, whenever you have time would you mind checking this approach, please? I just don't wanna overlook something by taking this path 😅 |
@@ -202,6 +203,11 @@ public Map getExportedCustomDirectEventTypeConstants() { | |||
|
|||
@ReactProp(name = "text") | |||
public void setText(ReactAztecText view, ReadableMap inputMap) { | |||
if (inputMap.hasKey(LINK_TEXT_COLOR_KEY)) { | |||
int color = Color.parseColor(inputMap.getString(LINK_TEXT_COLOR_KEY)); | |||
setLinkTextColor(view, color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that we will be constructing new LinkFormatter
and LinkStyle
objects on every text change, right? Seems like that is not ideal from a performance perspective, although any impact would probably be negligible. Still, maybe it's worth only updating the link formatter when the link color has changed. I do not feel strongly about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, maybe it's worth only updating the link formatter when the link color has changed.
So are you thinking something along the lines of this?
setLinkTextColor(view, color); | |
int color = Color.parseColor(inputMap.getString(LINK_TEXT_COLOR_KEY)); | |
if (view.linkFormatter.color != color) { | |
setLinkTextColor(view, color); |
Note I didn't test this suggestion out yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's pretty much what I was imagining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with that 👍 I'll work on making that change.
@@ -386,7 +392,6 @@ public void setTextAlign(ReactAztecText view, @Nullable String textAlign) { | |||
} | |||
} | |||
|
|||
@ReactProp(name = "linkTextColor", customType = "Color") | |||
public void setLinkTextColor(ReactAztecText view, @Nullable Integer color) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this private now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this private now. 👍
I think this approach makes sense. Seems like a good way to insure a proper order. I noted one small performance-related concern, but I don't think it's a big deal. An alternative approach that might work would be to reset the text any time the I haven't built this and tested it out, but looking at the code it looks good to me. 👍
+1000 to that! 🙂 |
I considered this a bit; however, other items ( |
@mchowning @geriux This is good to go again. I made the requested changes and migrated the code to Gutenberg as part of updating it with the monorepo changes. |
Also, I closed the main App PRs b/c of the monorepo work. So if it's not too much of a hassle can we test with the demo apps? |
Hey Chip 👋 The code looks good! I wanted to test on the demo apps but I don't know how to reproduce the bug in develop for example, so then I can switch to this branch and make sure it's fixed. Are there any steps to test a before and after in the demo app? I remember I was able to do it back then but with the main WordPress Android App. Or do you want me to just test that the changes didn't break anything? Let me know, thanks! |
Hey @geriux, I think for retesting making sure nothing breaks and trying multiple times to refresh the app should help. WPAndroid: wordpress-mobile/WordPress-Android#12226 (comment) |
Hey @chipsnyder 👋 thanks for bringing back the testing PRs =) On Android is working great 🎉 On iOS I noticed the colors are different after these changes:
This is not expected, right? Let me know, thanks! |
Hey @geriux, good catch. Were you running the metro server when you saw this? I totally missed this difference when I checked the builds but it looks like I just failed to rerun the bundle after merging monorepo. (I'll update the bundle and regenerate the builds) |
I used the IPA from the WordPress iOS PR without metro.
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved via WordPress/gutenberg#23289 (review)
Closing this PR as the Gutenberg changes will come with the next release |
Reopening to keep GB mobile and iOS in sync on the Pod Changes |
Closing this again. With wordpress-mobile/WordPress-iOS#14444 in place we can just follow the normal release process |
Fixes #2399
Related PRs:
gutenberg
WordPress/gutenberg#23289AztecEditor-iOS
wordpress-mobile/AztecEditor-iOS#1295WordPress-Android
wordpress-mobile/WordPress-Android#12226WordPress-iOS
wordpress-mobile/WordPress-iOS#14351Solution Description
As it turns out this error seems to be one that will randomly happen. Android uses the following process to set the text and style on RichText components:
linkFormatter
to determine the span and set the style This needs both the text and forlinkFormatter
to be set correctly.For the link color
linkTextColor
is set this updateslinkFormatter
with the proper attributes.The Issue
It appears that the
@ReactProp
's don't enforce an order of operations[1]. So iflinkTextColor
is processed beforetext
everything will work fine. If not then the app will fall back to the default styles.The Fix
To fix this I simply moved the
linkTextColor
to be part of thetext
attribute that is set so that we can enforce the order of operations.This is actually only needed for Android however to prevent diverging implementations I made the same changes to iOS.
To Test
Color should be using
blue-30
(#5198d9
)PR submission checklist:
RELEASE-NOTES.txt
if necessary.